﻿<?php
include("../public_files/conn.php");
session_start();
$user_id=$_SESSION['userid'];
if(isset($_POST['list_id'])){
$list_id=$_POST['list_id'];
$sql="delete from already_vote where list_id='$list_id' and user_id='$user_id'";
$result=mysql_query($sql)or die (mysql_error());

$count_vote=0;
$sql="select  * from already_vote where user_id='$user_id' order by id desc";
$result=mysql_query($sql)or die(mysql_error());
while($rows=mysql_fetch_array($result)){
		if($rows['offi_or_user']==0){
			$tabel="official_list_name";
			
		}else if($rows['offi_or_user']==1){
			$tabel="user_list_name";
	
		}


$list_id=$rows['list_id'];
$sqla="select  * from ".$tabel." where id='$list_id' ";
$resulta=mysql_query($sqla)or die(mysql_error());
$rowa=mysql_fetch_array($resulta);
		$status=$rowa['status'];
	if( $status==0 ){
		$count_vote++;
	}

}
echo $count_vote;


}

?>